package com.apes.scm.masterdata.finance.service;

import com.alibaba.fastjson.JSONObject;
import com.apes.framework.api.DomainService;
import com.apes.framework.plugin.esb.api.SimpleRequest;
import com.apes.scm.masterdata.finance.model.CrossDefiIC;
import com.apes.scm.masterdata.finance.model.CrossDept;
import com.apes.scm.masterdata.finance.repository.CrossDeptRepository;
import com.apes.scm.masterdata.frame.model.Dept;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @program: apes-server
 * @description
 * @author: czs
 * @create: 2021-06-29 16:22
 **/
@Service("crossDeptService")
public class CrossDeptService extends DomainService {
    @Autowired
    CrossDeptRepository crossDeptRepository;

    /**
     * 查找所有不可抵扣部门
     * 传入:CrossDefiIC crossDefiIC
     * @param request
     * @return deptList
     */
    public List<Dept> findAllCrossDefiIC(SimpleRequest request){
        CrossDefiIC crossDefiIC = request.getO(CrossDefiIC.class);
        List<CrossDept> allByCrossDefiIC = crossDeptRepository.findAllByCrossDefiIC(crossDefiIC);
        List<Dept> deptList = allByCrossDefiIC.stream().map(crossDept -> crossDept.getDept()).collect(Collectors.toList());
        return deptList;
    }


}
